<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html class="pixel-ratio-2 retina android android-6 android-6-0"><head>
    <title>湖南乐和信息技术有限公司</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="">

    <link rel="stylesheet" href="${ctx }/templates/default/skins/default/h5/lib/weui.min.css">
    <link rel="stylesheet" href="${ctx }/templates/default/skins/default/h5/css/jquery-weui.css">
    <link rel="stylesheet" href="${ctx }/templates/default/skins/default/h5/css/lehe.css">
<script type="text/javascript">navigator.__defineGetter__('userAgent', function () { return 'Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255'; });</script></head>

<body ontouchstart="">
<heaer>
    <div class="header">
        <a href="javascript:history.go(-1);" class="title">
            <span class="header-icon4"></span>
        </a>
        <span class="title-txt J-title-txt">下属充值</span>
    </div>
    <div class="header-secondary"></div>
</heaer>

<div class="weui-cells weui-cells_form" style="margin-top: 5px;">

    <div class="weui-cells__title " style="color:black;font-size:20px">本人剩余金币:<span style="font-size:22px;color:red;" id="myCount">${myCount }</span></div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <input id="search_uid" class="weui-input" type="text" placeholder="请输入要充值的玩家UID" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <input id="search_count" class="weui-input" type="text" placeholder="请输入要充值的金币数" />
            </div>
        </div>
    </div>

</div>

<div class="lehe-content-padded">
    <a id="search_player" class="weui-btn weui-btn_primary">查询</a>
</div>

<div id="playerinfo">

</div>

<script src="${ctx }/templates/default/skins/default/h5/lib/jquery-2.1.4.js"></script>
<script src="${ctx }/templates/default/skins/default/h5/lib/fastclick.js"></script>
<script>
    $(function() {
        FastClick.attach(document.body);
    });
</script>
<script src="${ctx }/templates/default/skins/default/h5/js/jquery-weui.js"></script>


<script>
    var new_uid = null;
    $(document).on("click", "#search_player", function() {
    	var uid = $("#search_uid").val();
    	var count = $("#search_count").val();
    	var myCount = $("#myCount").html();
    	if(uid == ""){
    		$("#search_uid").parents(".weui-cell").css("border","1px solid red")
    	}else{
    		$("#search_uid").parents(".weui-cell").css("border","")
    	}
    	
    	if(count == ""){
    		$("#search_count").parents(".weui-cell").css("border","1px solid red")
    	}else{
    		$("#search_count").parents(".weui-cell").css("border","")
    	}
    	if(count == "" && uid == ""){
    		$("#search_uid").parents(".weui-cell").css("border-bottom","")
    	}
    	if(count == "" || uid == ""){
    		return;
    	}
    	
    	if(eval(myCount) < count){
    		$.toast("你没有足够的金币", "forbidden");
    		return;
    	}
    	
        $.showLoading();

        $.post('../agent/query',{uid:uid},function(result){
            $.hideLoading();
            $("playerinfo").show();
            if(result && result.userId) {
                new_uid = result.userId;
                var html = '<header class="lehe-header">'
                        + '<h1 class="lehe-title"> 待充值玩家信息</h1>'
                        + '</header>'
                        + '<div class="weui-form-preview">'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">UID:</span>'
                        + '<span id="rs_uid" class="weui-form-preview__btn weui-form-preview__btn_primary">' + result.userId + '</span>'
                        + '</div>'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">玩家头像:</span>'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_primary">'
                        + '<img src="' + result.userImg + '" width="48">'
                        + '</span>'
                        + '</div>'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">昵称:</span>'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_primary">' + result.nickName + '</span>'
                        + '</div>'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">当前金币:</span>'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_primary" style="color:red;">' + result.goldCoinCount + '</span>'
                        + '</div>'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">本次充值:</span>'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_primary" style="color:red;">' + count + '</span>'
                        + '</div>'
                        + '<div class="weui-form-preview__ft">'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_default">本人剩余金币:</span>'
                        + '<span class="weui-form-preview__btn weui-form-preview__btn_primary" style="color:red;">' + (eval(myCount) - count) + '</span>'
                        + '</div>'



                        + '</div>'

                        + '<div class="lehe-content-padded">'
                        + '<a id="auth_button"  class="weui-btn weui-btn_primary">确定充值</a>'
                        + '</div>';
                $('#playerinfo').html(html);
            }else {
                $.toast("查询用户失败", "forbidden");
            }
        }, 'json');
    });
    $(document).on("click", "#auth_button", function() {
        $.showLoading();
        if(new_uid == null || new_uid == "") {
            $.toast("未找到任何数据", "forbidden");
            return;
        }
        var mobile = $("#mobile").val();
        var pwd = $("#pwd").val();
        var count = $("#search_count").val();
        $.post('../agent/charge/confrim',{uid:new_uid,count:count},function(result) {
            $.hideLoading();
            if(result.messageCode == 0) {
                var html = '<div class="weui-msg">'
                        + '<div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>'
                        + '<div class="weui-msg__text-area">'
                        + '<h2 class="weui-msg__title">充值成功！</h2>'
                        + '</div>'
                        + '<div class="weui-msg__opr-area">'
                        + '<p class="weui-btn-area">'
                        + '<a href="${ctx}" class="weui-btn weui-btn_default">刷新</a>'
                        + '</p>'
                        + '</div>'
                        + '</div>';
                $('#playerinfo').html(html);
                new_uid = null;
            }else{
                $.toast(result.messageValue, "forbidden");
            }
        }, 'json');
    });
</script></body></html>